import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/home' },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/films',
    name: 'Films',
    component: () => import('../views/Films/Films.vue'),
    children:[
      {
        path: 'nowPlaying',
        component: () => import('../views/Films/NowPlaying.vue')
      },
      {
        path: 'comingSoon',
        component: () => import('../views/Films/ComingSoon.vue')
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    // 异步组件
    component: () => import('../views/About.vue')
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import('../views/Detail.vue')
  },
  {
    path:'/*',
    component: () => import('../views/Error.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
